package mvn12.model;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

//Aspectj切面类
public class MyAspectJ {
	//前置增强/通知        连接点--获取目标对象的信息
	public void mybefore(JoinPoint jp) {
		System.out.println("前置增强被调用");
		System.out.println("目标对象："+jp.getTarget());
		System.out.println("目标方法名："+jp.getSignature().getName());
	}
	
	
	//后置增强/通知        连接点--获取目标对象的信息
	public void myReturning(JoinPoint jp,Object returnObj) {
		System.out.println("后置增强被调用");
		System.out.println("目标对象："+jp.getTarget());
		System.out.println("目标方法名："+jp.getSignature().getName());
		System.out.println("返回值："+returnObj);
	}
	
	//环绕增强/通知        连接点--获取目标对象的信息
	public Object myAround(ProceedingJoinPoint jp) throws Throwable {
		System.out.println("环绕增强被调用");
		//调用目标对象的方法
		Object obj = jp.proceed();
		//Object obj = null;
		System.out.println("环绕增强完成调用");
		return obj;
	}
	
	//异常抛出增强
	public void myCatch(JoinPoint jp ,Throwable e ) {
		System.err.println("异常通知："+e.getMessage());
		
	}
	
	//最终增强
	public void myfinally() {
		System.out.println("最终增强被执行");
	}
	


}
